<template>
	<view style="font-size:28rpx">
		<u-navbar :autoBack="true" leftIconColor="#ffffff" title="消息中心" :placeholder="true" bgColor="#3ACD90"  :titleStyle="{ color: '#FFFFFF', fontSize: '30rpx' }"></u-navbar>
		
		<view style="background-color: #ffffff;">
			<view class="mtlr30 cell-box-first" >
				<view>
					消息通知
				</view>
				<view style="color:#7D7D7D" @click="readAll">
					全部已读
				</view>
				
			</view>
		</view>
		
		<view class="mtlr30 cell-box-center" >
			<view class="mtlr30 cell-box" @click="viewNotice(1)">
				<view style="display: flex;">
					<view>
						<u-avatar shape="square" src="/static/image/accountState.png"></u-avatar>
					</view>
					<view>
						<u-badge  max="99" :value="firstCount"></u-badge>
					</view>
					
				</view>
				<view class="cell-box-title" style="display: flex;">
					账户状态提醒
				</view>
				
			</view>
			<view class="vertical-divider"></view>
			
			<view class="mtlr30 cell-box" @click="viewNotice(2)">
				<view style="display: flex;">
					<view>
						<u-avatar shape="square" src="/static/image/yejiState.png"></u-avatar>
					</view>
					<view>
						<u-badge  max="99" :value="secondCount"></u-badge>
					</view>
				</view>
				<view class="cell-box-title">
					业绩提醒
				</view>
				
			</view>
			<view class="vertical-divider"></view>
			
			<view class="mtlr30 cell-box" @click="viewNotice(3)">
				<view style="display: flex;">
					<view>
						<u-avatar shape="square" src="/static/image/sjState.png"></u-avatar>
					</view>
					<view>
						<u-badge  max="99" :value="thirdCount"></u-badge>
					</view>
				</view>
				<view class="cell-box-title">
					升降级提醒
				</view>
				
			</view>
			<view class="vertical-divider"></view>
			
			<view class="mtlr30 cell-box" @click="viewNotice(4)">
				<view style="display: flex;">
					<view>
						<u-avatar shape="square" src="/static/image/teamduliState.png"></u-avatar>
					</view>
					<view>
						<u-badge  max="99" :value="fourCount"></u-badge>
					</view>
				</view>
				<view class="cell-box-title">
					团队独立提醒
				</view>
				
			</view>
			<view class="vertical-divider"></view>
			
			<view class="mtlr30 cell-box" @click="viewNotice(5)">
				<view style="display: flex;">
					<view>
						<u-avatar shape="square" src="/static/image/teamhuiguiState.png"></u-avatar>
					</view>
					<view>
						<u-badge  max="99" :value="fiveCount"></u-badge>
					</view>
				</view>
				<view class="cell-box-title">
					团队回归提醒
				</view>
				
			</view>
			<view class="vertical-divider"></view>
			
			<view class="mtlr30 cell-box" @click="viewNotice(6)">
				<view style="display: flex;">
					<view>
						<u-avatar shape="square" src="/static/image/guishuState.png"></u-avatar>
					</view>
					<view>
						<u-badge  max="99" :value="sixCount"></u-badge>
					</view>
				</view>
				<view class="cell-box-title">
					归属变更提醒
				</view>
				
			</view>
			
			<view class="vertical-divider"></view>
			
			<view class="mtlr30 cell-box" @click="viewNotice(7)">
				<view style="display: flex;">
					<view>
						<u-avatar shape="square" src="/static/image/shopState.png"></u-avatar>
					</view>
					<view>
						<u-badge  max="99" :value="sevenCount"></u-badge>
					</view>
				</view>
				<view class="cell-box-title">
					店铺动态
				</view>
				
			</view>
			
		</view>
	</view>
</template>

<script>
import {
	noticeList,
	readNoticeAll
} from "@/common/apis/user.js"

export default{
	data(){
		return{
			firstCount:0,
			secondCount:0,
			thirdCount:0,
			fourCount:0,
			fiveCount:0,
			sixCount:0,
			sevenCount:0
		}
	},
	onLoad() {
		this.getMsgCount()
	},
	computed:{
		
	},
	methods:{
		getMsgCount(){
			noticeList({status:0}).then(res=>{
				console.log('res',res)
				if(res.status == 200){
					let result = res.data
					result.forEach(item => {
					  if(item.type_id == 1){
						  this.firstCount = item.count
					  }else if(item.type_id == 2){
						  this.secondCount = item.count
					  }else if(item.type_id == 3){
						  this.thirdCount = item.count
					  }else if(item.type_id == 4){
						  this.fourCount = item.count
					  }else if(item.type_id == 5){
						  this.fiveCount = item.count
					  }else if(item.type_id == 6){
						  this.sixCount = item.count
					  }else if(item.type_id == 7){
						  this.sevenCount = item.count
					  }
					});
			
				}
			})
			
		},
		viewNotice(type){
			this.$Router.push({
				path: '/pages/other/viewnotice',
				query:{
					type:type
				}
			})
		},
		readAll(){
			
			readNoticeAll().then( res=>{
				console.log('res',res)
				uni.showToast({
					title:"阅读成功",
					duration:2000
				})
				this.getMsgCount()
			})
		}
		
	}
}
</script>

<style scoped>
	.cell-box-first{
		padding: 20rpx 20rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	
	.cell-box-center{
		background-color: #ffffff;
		margin-top:30rpx;
		border-radius:20rpx ;
	}
	.cell-box{
		padding: 20rpx;
		display: flex;
		align-items: center;
	}
	.cell-box-title{
		margin-left:30rpx;
		font-size:30rpx
	}
	
	.vertical-divider {
		width: 100%;
		height: 2rpx;
		background-color: #D8D8D8;
	
	}
</style>